<div id="userpswmod" align="center">
<form name="pswmod_form" id="pswmod_form">
<input type="hidden" name="scid" value="user_updatepwd">
<input type="hidden" name="id" id="id" >
<table width="400px" height="100px">
	<tr>
		<td>原密码：</td>
		<td><input id="oldpassword" type="password" name="oldpassword" maxlength="20"  value="" /></td>
	</tr>
	<tr>
		<td>新密码：</td>
		<td><input id="newpassword" type="password" name="newpassword" maxlength="20" value="" /></td>
	</tr>
	<tr>
		<td>密码确认：</td>
		<td><input id="comfirmpwd" type="password" name="comfirmpwd" maxlength="20" value="" /></td>
	</tr>
	<tr collspan="2">
		<td width="78px" height="30px"><input name="bsubmit" id="bsubmit" type="button" value="提交" /><div id="submiting"></div></td>	
	</tr>
</table>
</form>
</div>
 

<script type="text/javascript">
var dataURL = '/data/sc.action';//取数据的url
var mainPanel = 'mainPanel';
var ret = -1;
var pwdvaliation = function(oldpassword,newpassword,confirmpassword){
	try {
		var request = new Request.JSON({
		url: dataURL,
		onComplete: function(json,text) {
			ret = json.error.errorcode ;
		}
	}).get({"scid":"user_checkpwd","oldpwd":oldpassword,  "newpwd":newpassword, "conpwd":confirmpassword});
	} catch (ex) {
		MUI.notification('<font color=red>错误：</font>(数据异常)');
	}
	return ret;
}

 window.addEvent('domready', function() {
	$('bsubmit').addEvent('click', function(e){
		//sumit事件开始
		$('pswmod_form').set('send', {
    		url: dataURL, 
    		onSuccess:function(responseText, responseXML){
    			$('bsubmit').set('disabled', false);
    			$('submiting').innerHTML = '';
    			var myjson = JSON.decode(responseText);
    			if (myjson.error.errorcode==0){
    				MUI.notification('修改成功！');
    				MUI.updateContent({
						'element':  $(mainPanel),
						//'url':      '/auth/users.action',
						'loadMethod':'html',
						'content':'操作完成，修改成功！'
					});
    			}else{
    				MUI.notification('<font color=red>错误：</font>('+myjson.error.retstring+')');
    			}
    		},
    		onFailure:function(instance){
    			MUI.notification('<font color=red>错误：</font>访问失败('+instance+')');
    			$('bsubmit').set('disabled', false);
    			$('submiting').innerHTML = '';
    		}
		});
		//sumit事件结束
		
		if($('oldpassword').get('value').trim() == ''){
			MUI.notification('<font color=red>错误：</font>(请输入原密码)');
			return;
		}
		if($('newpassword').get('value').trim() == ''){
			MUI.notification('<font color=red>错误：</font>(请输入新密码)');
			return;
		}
		if($('comfirmpwd').get('value').trim() == ''){
			MUI.notification('<font color=red>错误：</font>(请确认新密码)');
			return;
		}
		
		//点击submit开始
		try {
		var request = new Request.JSON({
			url: dataURL,
			onComplete: function(json,text) {
				ret = json.error.errorcode ;
				if( ret == 1 ){
					MUI.notification('<font color=red>错误：</font>(密码错误)');
					return;
				}else if( ret == 2 ){
					MUI.notification('<font color=red>错误：</font>(两次输入不相同)');
					return;
				}else if( ret == 0 ){ 
					$('bsubmit').set('disabled', true);
					$('submiting').innerHTML = '<img src="images/spinner.gif" width="16px" height="16px">';
					$('pswmod_form').send();
				}
			}
		}).get({"scid":"user_checkpwd","oldpwd":$('oldpassword').get('value'), 
				"newpwd": $('newpassword').get('value'), 
				"conpwd":$('comfirmpwd').get('value')});
		} catch (ex) {
			MUI.notification('<font color=red>错误：</font>(数据异常)');
		}
	
	}); //$('bsubmit').addEvent ...
	
	 
});

</script>